local faen = fk.CreateSkill{
    name = "wk_heg__faen",
}

local H = require "packages.ol_hegemony.util"

Fk:loadTranslationTable{
    ["wk_heg__faen"] = "法恩",
    [":wk_heg__faen"] = "与你势力相同的角色：1.横置后，你可令其摸一张牌；2.叠置后，其可弃置两张手牌，平置。",

    ["#wk_heg__faen_turn-invoke"] = "法恩：你可以弃置两张手牌，平置",
    ["#wk_heg__faen_chained-invoke"] = "法恩：你可以令其摸一张牌",

    ["$wk_heg__faen1"] = "礼法容情，皇恩浩荡。",
    ["$wk_heg__faen2"] = "法理有度，恩威并施。",
}

faen:addEffect(fk.TurnedOver,{
    can_trigger = function(self, event, target, player, data)
        if not (player:hasSkill(faen.name) and H.compareKingdomWith(player, target)) then return false end
        return (player:hasShownSkill(faen.name) or player == target) and target:getHandcardNum() >= 2 and not target.faceup
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askToSkillInvoke(target, {skill_name = faen.name, prompt = "#wk_heg__faen_turn-invoke"})
    end,
    on_use = function(self, event, target, player, data)
        player.room:askToDiscard(target,{
            min_num = 2,
            max_num = 2,
            include_equip = false,
            skill_name = faen.name,
            cancelable = false,
        })
        target:turnOver()
    end,
})

faen:addEffect(fk.ChainStateChanged,{
    can_trigger = function(self, event, target, player, data)
       if not (player:hasSkill(faen.name) and H.compareKingdomWith(player, target)) then return false end
       return target.chained
    end,
    on_use = function(self, event, target, player, data)
        target:drawCards(1, faen.name)
    end,
})

return faen